package com.mercury.pattern._03_prototype._002_shallow;

/**
 * 浅拷贝方式
 *  特点：1、实现 Cloneable 接口
 *       2、对于基本数据类型和String会进行值拷贝。
 *          对于对象，会拷贝地址；但是不会把对象再拷贝一份
 */
public class Center {

    public static void main(String[] args) {
        System.out.println("浅拷贝方式~");
        Sheep sheep = new Sheep("tom", 10, "白色");
        Sheep jack = new Sheep("jack", 10, "黑色");
        sheep.setSheep(jack);

        Sheep clone1 = sheep.clone();
        Sheep clone2 = sheep.clone();
        Sheep clone3 = sheep.clone();
        Sheep clone4 = sheep.clone();
        Sheep clone5 = sheep.clone();

        System.out.println(sheep.getName() + "=======" + clone1.getName());

        System.out.println(sheep == clone1);

        System.out.println(sheep.getSheep() == clone1.getSheep());
    }
}
